var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var app = getApp();

Page({
  data: {

    serviceList:[],
    phone:''
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    this.getServiceList();

  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示

  },
  // 获取配置信息
  getServiceList (){

    let that = this;
 
    util.request(api.ConfRequest,{type:'CONTACT_SERVICE'}).then(res=>{

        console.log(res)
        if(res.code == 200){

          var serviceList = res.responseBody
          var ph = ""

          for ( var i = 0; i <serviceList.length; i++){
            console.log(serviceList[i]);
            if(serviceList[i].key == "客服电话"){
                ph = serviceList[i].value
                break
            }
          }

          that.setData({
              phone: ph
          })
        }
    })
     
  },
  // 电话拨打
  tel:function(e){
     var that = this;

      wx.makePhoneCall({
        phoneNumber: that.data.phone, //此号码仅用于测试 。
        success: function (res) {
          console.log("拨打电话成功！")
          console.log(res)
        },
        fail: function () {
          console.log("拨打电话失败！")
        }
      })

   
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  }
})